tools: Adjust tools' path calculation.
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 20 Jun 2007 16:07:15 +0000 (17:07 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 20 Jun 2007 16:07:15 +0000 (17:07 +0100)
I'm suggesting this change to make another tiny step towards the
ability to run the tools e.g. out of the build tree (so that multiple
different Xen versions can co-exist without the requirement to
re-install the respective version with each boot).

Signed-off-by: Jan Beulich <jbeulich@novell.com>
tools/misc/xen-python-path
tools/python/xen/util/auxbin.py

index da3d2dd2ba7a50517ba547b6e34cd12fcb63621d..57774a332b9bad45f882c03a6b5a58e9f4f358f1 100644 (file)
@@ -28,8 +28,13 @@ import os
 import os.path
 import sys
 
-for p in ['python%s' % sys.version[:3], 'python']:
-    for l in ['/usr/lib64', '/usr/lib']:
+usr   = os.path.dirname(os.path.dirname(sys.argv[0]))
+list  = [ os.path.join(usr,'lib64') ]
+list += [ os.path.join(usr,'lib') ]
+list += ['/usr/lib64', '/usr/lib']
+
+for l in list:
+    for p in ['python%s' % sys.version[:3], 'python']:
         for k in ['', 'site-packages/']:
             d = os.path.join(l, p, k)
             if os.path.exists(os.path.join(d, AUXBIN)):
index 5d2066157c07034f9ed0b19df1a51fd71358b174..75e38a838e79f3ccd8575039420e58caa481107f 100644 (file)
@@ -27,6 +27,7 @@ LIB_64_ARCHS = [ 'x86_64', 's390x', 'sparc64']
 
 import os
 import os.path
+import sys
 
 
 def execute(exe, args = None):
@@ -47,6 +48,14 @@ def path():
 
 def libpath():
     machine = os.uname()[4]
+    if sys.argv[0] != '-c':
+        prefix = os.path.dirname(os.path.dirname(sys.argv[0]))
+        path = os.path.join(prefix, os.path.basename(LIB_64))
+        if machine in LIB_64_ARCHS and os.path.exists(path):
+            return path
+        path = os.path.join(prefix, os.path.basename(LIB_32))
+        if os.path.exists(path):
+            return path
     if machine in LIB_64_ARCHS and os.path.exists(LIB_64):
         return LIB_64
     else: